package com.qf.ems.controller;

import com.alibaba.fastjson.JSON;
import com.qf.ems.entity.Emp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/manage/safe/showAllEmp1")
public class ShowAllEmpController1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Emp jack = new Emp(1, "jack", 3000, 28);
        Emp tony = new Emp(2, "tony", 3000, 28);
        ArrayList<Emp> emps = new ArrayList<>();
        emps.add(jack);
        emps.add(tony);
        String s = JSON.toJSONString(emps);
        resp.setContentType("text/json;charset=utf-8");
        resp.getWriter().write(s);
    }
}
